# -- coding: utf-8 --
# @time :
# @author : 周梦泽
# @file : .py
# @software: pycharm
from common.logger.log import log_
from common.utils.web_page_util import MockTap


def select_days(page, day: int):
    """
    选择天数小组件
    :param page:
    :param day:选择的天数
    :return:page
    """

    if day == 7:
        log_.info('正在点击7天')
        day7_ele = page.ele("x://span[text()='7天']")
        MockTap(ele=day7_ele, msg='没找到元素', before_delay=(3, 6))()

    elif day == 30:
        try:
            log_.info('正在点击30天')
            day30_ele = page.ele("x://span[text()='30天']")
            MockTap(ele=day30_ele, msg='没找到元素', before_delay=(3, 6))()
        except Exception:
            log_.info('没找到30天, 账号没有30天权限, 正在点击7天')
            day7_ele = page.ele("x://span[text()='7天']")
            MockTap(ele=day7_ele, msg='没找到元素', before_delay=(3, 6))()
            day = 7

    return page, day
